package com.rxkj.controller;

import com.rxkj.entity.sys.SysOprateLog;
import com.rxkj.service.SysOPLogService;
import com.rxkj.utils.PageData;
import com.rxkj.utils.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/sys/syslog")
@Api(tags = "系统操作日志")
public class SysLogController {

    private static Logger logger = LoggerFactory.getLogger(SysLogController.class);

    @Autowired
    private SysOPLogService sysOPLogService;

    //@RoleLevel(2)
    @PostMapping("/querySysLog")
    @ApiOperation("查询日志记录")
    @ApiImplicitParams({
        @ApiImplicitParam(name = "currentPage", required = true, value = "当前页码"),
        @ApiImplicitParam(name = "pageSize", required = true, value = "每页条数")
    })
    public ResponseResult querySysLog(@RequestParam("currentPage") int currentPage,
                                      @RequestParam("pageSize") int pageSize){
        try {
            PageData<SysOprateLog> qe = sysOPLogService.querySysLog(currentPage, pageSize);
            return ResponseResult.success("查询成功", qe);
        } catch (Exception e) {
            logger.error("查询出现错误..");
            e.printStackTrace();
        }
        return ResponseResult.error("查询失败");
    }


}
